<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('money_sub_categories', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('category_id')->comment('所属主分类ID');
            $table->string('icon', 50)->comment('子分类图标');
            $table->string('name', 50)->comment('子分类名称');
            $table->integer('sort')->default(0)->comment('排序');
            $table->string('description', 255)->nullable()->comment('子分类描述');
            $table->timestamps();

            $table->foreign('category_id')->references('id')->on('money_categories')->onDelete('cascade');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('money_sub_categories');
    }
};
